const autoprefixer = require('autoprefixer')
const pxtoviewport = require('postcss-px-to-viewport')

module.exports = {
  lintOnSave: false,
  outputDir: 'dist',
  publicPath: process.env.NODE_ENV === 'production' ? '/douban-movie/' : '/',
  css: {
    loaderOptions: {
      postcss: {
        plugins: [
          autoprefixer(),
          // Viewport 布局
          pxtoviewport({
            viewportWidth: 375,
            propList: ['*'],
            exclude: [/node_modules/],
            minPixelValue: 16,
          }),
        ],
      },
    },
  },
  // 反向代理
  devServer: {
    proxy: {
      '/douban': {
        target: 'http://api.douban.com',
        changeOrigin: true,
        pathRewrite: {
          '^/douban': '',
        },
      },
    },
  },
}
